<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <script src="./lib/vue2.4.4.js"></script>
    <script src="./lib/vue-router3.0.1.js"></script>
</head>

<body>
    <div id="app">
        <router-link to="/account">Account</router-link>
        <router-view></router-view>
    </div>

    <template id="accountTpl">
        <div>
            <h1>这是 Account 组件</h1>
            <router-link to="/account/login/10/zs">登录</router-link>
            <router-link to="/account/register">注册</router-link>
            <router-view></router-view>
        </div>
    </template>
    <template id="loginTpl">
        <h1>登录组件 --- {{$route.params.id}} --- {{$route.params.name}}</h1>
    </template>
    <template id="registerTpl">
        <h1>注册组件</h1>
    </template>

    <script>

        var accountComponent = {
            template: '#accountTpl'
        }

        var loginComponent = {
            template: '#loginTpl',
            created() {
                console.log(this.$route)
            }
        }

        var registerComponent = {
            template: '#registerTpl'
        }

        var router = new VueRouter({
            linkActiveClass: 'myactiveclass foo',
            routes: [
                {
                    path: '/account',
                    component: accountComponent,
                    children: [
                        {
                            path: 'login/:id/:name',
                            component: loginComponent
                        },{
                            path: 'register',
                            component: registerComponent
                        }
                    ]
                }
                // ,{
                //     path: '/account/login/:id/:name',
                //     component: loginComponent
                // }, {
                //     path: '/account/register',
                //     component: registerComponent
                // }
            ]
        })

        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            router
        })
    </script>
</body>

</html>